<?php

namespace app\services;

use app\model\CodPerformance;

class CodPerformanceService
{


    /**
     * @var CodPerformance
     */
    private $dao;


    public function __construct()
    {
        $this->dao = new CodPerformance();
    }

    public function add($data)
    {
        return $this->dao->create($data);
    }

    public function addBatch(array $data)
    {
        return $this->dao->saveAll($data);
    }


    public function setBatchSaveCodPerformanceList($orderArr)
    {
        $result = [];

        $fields = [
            'financial_code', 'sequence_number', 'department', 'supplier',
            'payment_status', 'settlement_method', 'customer_name', 'original_price_MOP', 'original_price_HKD', 'original_price_RMB',
            'original_price_MOP_swipe', 'original_price_HKD_swipe', 'original_price_RMB_swipe',
            'base_price_MOP', 'base_price_HKD', 'base_price_RMB',
            'reservation_date', 'product_category', 'order_serial_number',
            'GTD_serial_number', 'purchase_method', 'product_name', 'room_type_name',
            'rooms_beds', 'nights_persons', 'total', 'air_ticket_number', 'checkin_start_date',
            'checkout_end_date', 'receipt_number', 'customer_order_number', 'commission_MOP', 'commission_HKD', 'commission_RMB',
            'collection_MOP', 'collection_HKD', 'collection_RMB', 'gross_profit_MOP', 'HKD_to_RMB_exchange_rate',
            'converted_price_RMB', 'field_service_fee_MOP', 'field_service_fee_HKD', 'field_service_fee_RMB', 'cash_coupon_MOP',
            'cash_coupon_HKD', 'cash_coupon_RMB', 'extra_bed_HKD', 'extra_bed_RMB', 'breakfast_MOP', 'breakfast_HKD', 'breakfast_RMB',
            'payment_time', 'guest_name', 'follow_up_staff', 'entry_staff', 'old_member', 'customer_area', 'salesman',
            'related_order_number', 'remarks', 'customer_source', 'supplier_expenditure', 'company'
        ];


        foreach ($fields as $key => $field) {
            $result[$field] = $orderArr[$key];
        }

        return $result;
    }


}